<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/juggle-all.js" type="text/javascript"></script>
    <script type="text/javascript">
        function success(event) {
            alert("发送post请求返回" + event.mData);
        }
        function error(event) {
            alert("发送post请求返回错误");
        }
        function successFile(event) {
            alert("发送文件请求" + event.mData);
        }
        function errorFile(event) {
            alert("发送文件请求返回错误");
        }
        window.onload = function () {
            var data = {
                'hOpCode': '1',
                'userName': 'hello',
                'userPassword': '123456'
            };
            var header = [];
            header["token"] = "sadwadawdwad";
            var httpClient = new juggle.HttpClient();
            httpClient.send(data, "http://localhost:8080/httpserver-test/s", header);
            httpClient.addEventListener(juggle.httpEventType.SUCCESS, success, this);
            httpClient.addEventListener(juggle.httpEventType.ERROR, error, this);


            document.getElementById("sendDemoTest").addEventListener("click", sendFileTest);
        };
        function sendFileTest() {
            var obj = document.getElementById("userImg");
            var data = {
                'hOpCode': '1',
                'userName': 'hello',
                'userPassword': '123456'
            };
            var header = [];
            header["token"] = "sadwadawdwad";
            var httpClient = new juggle.HttpClient();
            httpClient.sendFile(obj.files, data, "http://localhost:8080/httpserver-test/s", header);
            httpClient.addEventListener(juggle.httpEventType.SUCCESS, successFile, this);
            httpClient.addEventListener(juggle.httpEventType.ERROR, errorFile, this);
        }
    </script>
</head>
<body>
<div>
    <input type="file" id="userImg" name="uploadFiles"/>
    <input type="button" value="发送请求" id="sendDemoTest"/>
</div>
</body>
</html>